#include <stdio.h>
#include <math.h>
// 3.1摄氏度转华氏度
int question1()
{
    float f, c;
    f = 64.0;
    c = (5.0 / 9) * (f - 32);
    printf("f=%f\nc=%f\n", f, c);
    return 0;
}

// 3.2计算存款利息
int question2()
{
    float p0 = 1000, r1 = 0.0036, r2 = 0.0225, r3 = 0.0198, p1, p2, p3;

    p1 = p0 * (1 + r1); // 计算活期
    p2 = p0 * (1 + r2); // 计算一年定期本息和
    p3 = p0 * (1 + r3 / 2) * (1 + r3 / 2);
    printf("p1=%f\np2=%f\np3=%f\n", p1, p2, p3);
    return 0;
}
// 3.3 大写变小写
int question3()
{
    char c1, c2;
    c1 = 'A';
    c2 = c1 + 32;
    printf("%c\n", c2);
    printf("%d\n", c2);
    return 0;
}

// 3.4 求三角形面积
int question4()
{
    double a, b, c, s, area;
    a = 3.67;
    b = 5.43;
    c = 6.21;
    s = (a + b + c) / 2;                          // 计算s
    area = sqrt(s * (s - a) * (s - b) * (s - c)); // 计算area
    printf("a=%f\tb=%f\tc=%f\n", a, b, c);
    printf("area=%f\n", area);
    return 0;
}
// 3.5 求一元二次方程的根
int question5()
{
    double a, b, c, disc, x1, x2, p, q; // disc为根的判别式
    scanf("%lf%lf%lf", &a, &b, &c);     // 输入双精度变量的值要用格式声明"%lf"
    disc = b * b - 4 * a * c;
    p = -b / (2.0 / a);
    q = sqrt(disc) / (2.0 / a);
    x1 = p + q;
    x2 = p - q;
    printf("x1=%7.2f\nx2=%7.2f\n", x1, x2);
    return 0;
}
// 3.6 用%f输出实数，只能得到6位小数
int question6()
{
    double a = 1.0;
    printf("%f\n", a / 3);
    return 0;
}

// 3.7 float型数据的有效位数
int question7()
{
    double a;
    a = 10000 / 3.0;
    printf("%f\n", a);
    return 0;
}

// 3.8 先后输出BOY三个字符
int question8()
{
    // char a='B',b='O',c='Y';
    int a = 66, b = 79, c = 89;
    putchar(a);
    putchar(b);
    putchar(c);
    putchar('\n');
    return 0;
}

// 3.9 键盘输入COOL
int question9()
{

    char a, b, c, d;
    a = getchar();
    b = getchar();
    c = getchar();
    d = getchar();
    putchar(a);
    putchar(b);
    putchar(c);
    putchar(d);
    putchar('\n');
    return 0;
}
// 3.10 输入大写，输出小写
int question10()
{
    char c1, c2;
    c1 = getchar();
    c2 = c1 + 32;
    putchar(c2);
    putchar('\n');
    return 0;
}
int main()
{
    question10();
    return 0;
}
